<template>
  <div class="app-container org">
    <!-- 左侧区域 -->
    <el-card style="width: 100%">
      <el-tabs v-model="activityName" class="demo-tabs">
        <el-tab-pane label="未评审方案列表" name="first">
          <isReviewed v-if="activityName == 'first'" @projectId="projectId" ref="isReviewedRef"/>
        </el-tab-pane>
        <el-tab-pane label="已评审方案列表" name="second">
          <isReviewed
            v-if="activityName == 'second'"
            ref="isReviewedRef"
            :step="2"
            @projectId2="projectId2"
          />
        </el-tab-pane>
        <el-tab-pane label="方案详情" name="three" :disabled="true">
          <schemeDetails
            v-if="activityName == 'three'"
            :projectId="form.projectId"
            :isdisabel="isdisabel"
            ref="schemeDetailsRef"
          />
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<script setup name="ProjectCheck">
import isReviewed from "./components/isReviewed";
import schemeDetails from "./components/schemeDetails";
const route = useRoute();
const form = ref({});
const isdisabel = ref();
const schemeDetailsRef = ref(null)
const isReviewedRef = ref(null)

const activityName = ref("first");
function projectId(val) {
  activityName.value = "three";
  form.value.projectId = val;
  isdisabel.value = true;
}

function projectId2(val) {
  activityName.value = "three";
  form.value.projectId = val;
  isdisabel.value = false;
}
onMounted(() => {
  nextTick(() => {
    isReviewedRef.value?.getTableHeight()
    if (route.query.projectId) {
      form.value.projectId = route.query.projectId.split("_")[1];
      activityName.value = "three";
      isdisabel.value = true;
      nextTick(() => {
        schemeDetailsRef.value.getTableHeight()
      })
    } else {
      delete form.value.projectId;
      activityName.value = "first";
      isdisabel.value = true;
    }
  });
});
onUpdated(() => {
  nextTick(() => {
    isReviewedRef.value?.getTableHeight()
    if (route.query.projectId) {
      form.value.projectId = route.query.projectId.split("_")[1];
      activityName.value = "three";
      isdisabel.value = true;
      nextTick(() => {
        schemeDetailsRef.value.getTableHeight()
      })
    } else {
      delete form.value.projectId;
      activityName.value = "first";
      isdisabel.value = true;
    }
  });
});
</script>

<style></style>
